package com.ruoyi.web.tool;

import lombok.ToString;

import java.io.Serializable;

/**
 * @ClassName: ResultCode
 * @Description:
 * @Author: liurb
 * @Date: 2022/8/19 15:52
 * @Version: 1.0
 **/
@ToString
public enum ResultCode implements IBaseEnum<Integer>, Serializable {

    USER_ERROR(100, "用户端错误"),
    USER_LOGIN_ERROR(101, "用户登录异常"),
    USER_NOT_EXISTS(102, "用户不存在"),
    USER_ACCOUNT_LOCKED(103, "用户帐号被冻结"),
    USER_ACCOUNT_INVALID(104, "用户帐号已注销"),
    USER_NAME_OR_PASSWD_ERROR(105, "用户名或密码错误"),
    PASSWD_ENTER_EXCEED_LIMIT(106, "用户输入密码次数超限"),
    USER_ALREADY_EXISTS(107, "用户已存在"),
    USER_UNREALIZED_AUTHENTICATION(108, "用户未实名认证"),

    SUCCESS(200, "操作成功"),
    CLIENT_AUTHENTICATION_FAILED(212, "客户端认证失败"),
    TOKEN_INVALID_OR_EXPIRED(230, "token无效或已过期"),
    TOKEN_ACCESS_FORBIDDEN(231, "token已被禁止访问"),

    FAILED(300, "操作失败"),
    AUTHORIZED_ERROR(301, "访问权限异常"),
    ACCESS_UNAUTHORIZED(302, "访问未授权"),
    ORDER_UNPAID(303,"订单未支付"),

    PARAM_ERROR(400, "用户请求参数错误"),
    RESOURCE_NOT_FOUND(401, "请求资源不存在"),
    PARAM_IS_NULL(410, "请求必填参数为空"),
    RESOURCE_STATUS_ERROR(402, "请求资源状态错误"),

    SYSTEM_EXECUTION_ERROR(500, "系统繁忙,请稍候再试!"),
    SYSTEM_EXECUTION_TIMEOUT(501, "系统执行超时"),

    SIGNING_PARAM_ERROR(510, "接口验签入参缺失，拒绝服务"),
    SIGNING_NOT_SIGN_DATA(511, "签名数据不存在，拒绝服务"),
    SIGNING_EXPIRE_OFF(511, "签名已过期，拒绝服务"),
    SIGNING_DATA_ERROR(513, "签名数据不正确，拒绝服务"),


    SYSTEM_DISASTER_RECOVERY_TRIGGER(600, "系统容灾功能被出发"),
    FLOW_LIMITING(601, "系统限流"),
    DEGRADATION(602, "系统功能降级"),
    SYSTEM_RESOURCE_ERROR(603, "系统资源异常"),
    SYSTEM_RESOURCE_EXHAUSTION(604, "系统资源耗尽"),
    SYSTEM_RESOURCE_ACCESS_ERROR(605, "系统资源访问异常"),
    SYSTEM_READ_DISK_FILE_ERROR(606, "系统读取磁盘文件失败"),

    USER_UPLOAD_FILE_ERROR(700, "用户上传文件异常"),
    USER_UPLOAD_FILE_TYPE_NOT_MATCH(701, "用户上传文件类型不匹配"),
    USER_UPLOAD_FILE_SIZE_EXCEEDS(702, "用户上传文件太大"),
    USER_UPLOAD_IMAGE_SIZE_EXCEEDS(703, "用户上传图片太大"),
    USER_UPLOAD_TEXT_CONTENT_NOT_COMPLIANT(704, "文本内容不合规"),
    BAIDU_EXAMINE_NO_PASS(705, "百度审核不通过"),

    CALL_THIRD_PARTY_SERVICE_ERROR(701, "调用第三方服务出错"),
    MIDDLEWARE_SERVICE_ERROR(702, "中间件服务出错"),
    INTERFACE_NOT_EXIST(703, "接口不存在"),

    MESSAGE_SERVICE_ERROR(801, "消息服务出错"),
    MESSAGE_DELIVERY_ERROR(802, "消息投递出错"),
    MESSAGE_CONSUMPTION_ERROR(803, "消息消费出错"),
    MESSAGE_SUBSCRIPTION_ERROR(804, "消息订阅出错"),
    MESSAGE_GROUP_NOT_FOUND(805, "消息分组未查到"),

    DATABASE_ERROR(901, "数据库服务出错"),
    DATABASE_TABLE_NOT_EXIST(902, "表不存在"),
    DATABASE_COLUMN_NOT_EXIST(903, "列不存在"),
    DATABASE_DUPLICATE_COLUMN_NAME(904, "多表关联中存在多个相同名称的列"),
    DATABASE_DEADLOCK(905, "数据库死锁"),
    DATABASE_PRIMARY_KEY_CONFLICT(906, "主键冲突"),

    SYSTEM_SHOP_PROHIBIT(1001, "店铺已封禁"),
    SYSTEM_SHOP_NOT_EXISTS(1002,"您还不是俱乐部商家，是否进行商家入驻"),
    SYSTEM_SHOP_PENDING_APPROVAL(1004,"您店铺处于待审中..."),
    SYSTEM_SHOP_NOT_APPROVAL(1005,"您店铺审核不通过"),
    SYSTEM_SHOP_NOT_AUDIT(1006,"您店铺未审核"),


    USEREXPERT_NO_EXIST(1101,"用户未申请达人，是否升级达人"),
    USEREXPERT_YES_EXIST(1102,"用户已申请达人，无需重新提交"),

    ;


    private Integer value;

    private String description;


    ResultCode(Integer value, String description) {
        this.value = value;
        this.description = description;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String description() {
        return this.description;
    }


    public static ResultCode getValue(Integer value) {
        for (ResultCode code : values()) {
            if (code.value.equals(value)) {
                return code;
            }
        }
        //默认系统执行错误
        return SYSTEM_EXECUTION_ERROR;
    }
}
